﻿using System;
using System.Collections.Generic;
using System.Linq;
using Data.implement;

namespace Data
{
    class LocationRepositery : DataAccessBase<LYWebsiteSEntities1>, ILocationRepositery
    {
        private static readonly log4net.ILog log =
            log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        private static List<Location> AllLocations; 
        public Location GetLocation(int Id)
        {
            log.InfoFormat("LocationRepositery.GetLocation({0})",Id);
            return GetAllLocations().FirstOrDefault(d => d.LocationId == Id);
        }

        public List<Location> GetAllLocations()
        {
            log.InfoFormat("LocationRepositery.GetAllLocations()");
            if(AllLocations == null || AllLocations.Count == 0)
                AllLocations = GetAllRecord<Location>();
            return AllLocations;
        }
    }
}